#include <bits/stdc++.h>
using namespace std;
const int N = 5010, mod = 1'000'000'007;
int n, m, k;
int f[N][N], s[N], l[N], y[N], cnt[30];
inline int qexp(int x, int k) {
  int s = 1;
  while (k) {
    if (k & 1) s = (1LL * s * x) % mod;
    x = (1LL * x * x) % mod;
    k >>= 1;
  }
  return s;
}
int main() {
  cin >> n >> m >> k;
  s[0] = 1;
  for (int i = 1; i <= n; ++i) cin >> l[i] >> y[i];
  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (i >= l[j]) {
        f[i][y[j]] = (f[i][y[j]] + s[i - l[j]]) % mod;
        s[i] = (s[i] + s[i - l[j]]) % mod;
      }
    }
  }
  for (int i = 1; i <= m; ++i) {
    char ch;
    cin >> ch;
    cnt[ch - 'A']++;
  }
  int res = 1;
  for (int i = 0; i < 26; ++i) {
    if (!cnt[i]) continue;
    int ans = 0;
    for (int j = 1; j <= n; ++j) {
      if (f[k][j]) ans = (ans + qexp(f[k][j], cnt[i])) % mod;
    }
    res = 1LL * res * ans % mod;
  }
  cout << res << endl;
}
